package cn.lf.android.lawfirm.undertake.approval.view;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.lf.android.lawfirm.R;
import cn.lf.android.lawfirm.undertake.approval.modle.LawyerFee;

import static cn.lf.android.lawfirm.R.id.creat_people;
import static cn.lf.android.lawfirm.R.id.head_left;

public class LawyerFeeAdapter extends BaseAdapter {
    private List<LawyerFee> list;
    private LayoutInflater inflater;
    private Activity context;
    private int mPosition = 0;
    int width = 0;
    /**
     * 0-承办审批
     **/
    private int type;

    public LawyerFeeAdapter(Activity context, List<LawyerFee> list, int type) {
        this.context = context;
        this.list = list;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_law_distribution, null);
            holder.names = (TextView) convertView
                    .findViewById(R.id.names);
            holder.team = (TextView) convertView
                    .findViewById(R.id.team);
            holder.creat_people = (TextView) convertView
                    .findViewById(creat_people);
            holder.right_two = (TextView) convertView
                    .findViewById(R.id.right_two);
            holder.right_one = (TextView) convertView
                    .findViewById(R.id.right_one);
            holder.head_right = (TextView) convertView
                    .findViewById(R.id.head_right);
            holder.head_left = (TextView) convertView
                    .findViewById(head_left);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final LawyerFee bean = list.get(position);

        holder.names.setText("款项名称：" + bean.paymentName);
        holder.team.setText("律师费：" + bean.shouldCharge);
        holder.creat_people.setText("收款条件：" + bean.condition);
//        if (bean.expectGatheringDate.length() > 8) {
//            String str = bean.expectGatheringDate.substring(0,bean.expectGatheringDate.length() - 8);
//            holder.head_left.setText("收费时间：" + str);
//        } else {
            holder.head_left.setText("收费时间：" + bean.expectGatheringDate);
//        }

        holder.head_right.setText("");
        holder.right_one.setVisibility(View.GONE);
        holder.right_two.setVisibility(View.GONE);
        return convertView;
    }

    class ViewHolder {
        TextView head_left, head_right, names, team, creat_people, right_two, right_one;
    }

}
